package com.itheima.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

public class AOPAdvice {

    public void before(JoinPoint jp){
        Object[] args = jp.getArgs();
        System.out.println("before..."+ args[0]);
    }

    public void after(){
        System.out.println("after...");
    }
    public void afterReturning(Object ob){

        System.out.println("afterReturning..." + ob);

    }
    public void afterThrowing(Throwable t){

        System.out.println("afterThrowing..."+t.getMessage());
    }
    public Object arround(ProceedingJoinPoint pjp) {
     /*   Object[] args = pjp.getArgs();
        System.out.println("arround...   " + args[0]);
        pjp.proceed();
        System.out.println("arround...");*/

        Object ret = null;
        try {
            ret = pjp.proceed();
        } catch (Throwable t) {
            System.out.println( t.getMessage());

        }
        /*   System.out.println("arround>>>>>>>>>>>>>"+ proceed);*/
        return ret;

    }



}
